package com.liuyk.service;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;

import androidx.annotation.Nullable;

import com.liuyk.main.activity.AidlApkInfoManager;
import com.liuyk.main.activity.ApkInfo;

import java.util.ArrayList;
import java.util.List;

/**
 * DESC
 * <p>
 * Created by Administrator on 2020/1/10.
 */
public class AidlService extends Service {

    private List<ApkInfo> datas;

    @Override
    public void onCreate() {
        super.onCreate();
        datas = new ArrayList<>();
    }

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return new AidlManager();
    }

    public class AidlManager extends AidlApkInfoManager.Stub {

        @Override
        public void addApk(ApkInfo apk) throws RemoteException {
            datas.add(apk);
        }

        @Override
        public ApkInfo getApkInfo() throws RemoteException {
            return datas.get(0);
        }
    }
}
